﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rongzi.Infrastructure.ServiceBus.Queue;

namespace RabbitMQConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //RabbitMQLazyMessageTest test = new RabbitMQLazyMessageTest();
                //test.SubscribeDelayMessage<AppyInfoDeliveryMessage>(x => Console.WriteLine($"receive message time is:{DateTime.Now.ToString()},id is:{x.RequirementId}"), 2);
                //test.PublishDelayMessage<AppyInfoDeliveryMessage>(new AppyInfoDeliveryMessage { RequirementId = "hello world" }, expireMinutes: 2);
                //Console.WriteLine($"publish time is {DateTime.Now.ToString()}");

                var test = RabbitMQProvider.Instance;
                test.SubscribeDelayMessage<AppyInfoDeliveryMessage>(x => Console.WriteLine($"receive message time is:{DateTime.Now.ToString()},id is:{x.RequirementId}"), 1);
                test.PublishDelayMessage<AppyInfoDeliveryMessage>(new AppyInfoDeliveryMessage { RequirementId = "hello world" }, expireMinutes: 1);
            
                Console.WriteLine($"publish time is {DateTime.Now.ToString()}");

                Console.ReadLine();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ReadLine();
            }
        }
    }
}
